﻿{template 'header'}

<body>
    <link rel="stylesheet" type="text/css" href="{$url['style']}/css/main.css" />
    <div class="bg_music">
        <audio id="bg_music" autoplay="autoplay" loop src="{$url['style']}/SilverScrapes.mp3"></audio>
        <a href="javascript:;" onClick="playOrPaused(this)">播放</a>
    </div>
    <div id="contentdiv">
        <div id="startdiv">
            <div class="start_wp">
                {if $isfollow}
                <button onClick="begin()">开始游戏</button>
                {else}
                    {if $setting['ewm']}
                        <img src="../attachment/{$setting['ewm']}" alt="" width="120px" height="120px"> 
                    {else}
                        <p>请配置二维码</p>
                    {/if}
                <p style="margin: 10px;"><a href="{$url['link']}">请关注后点击此处刷新</a></p>
                {/if}
            </div>
        </div>
        <div id="maindiv" {if $setting[ 'bgimage']} style="background-image: url(../attachment/{$setting['bgimage']});" {/if}>
            <div id="scorediv">
                <label>分数：</label>
                <label id="label">0</label>
            </div>
            <div class="sus_wp">
                <div id="suspenddiv">
                    <button>继续</button><br/>
                    <button>重新开始</button>
                </div>
            </div>
            <div class="end_wp">
                <div id="enddiv">
                    <p class="plantext">得分</p>
                    <p id="planscore">0</p>
                    <div class="btn_wp">
                        <!-- <p><button class="dh_btn">领取奖品</button></p> -->
                        <p><button onClick="jixu()">再打一次</button></p>
                        <p><button class="zf_bt"><b>查看排行榜</b></button></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <style>
        .rank {
            width: 95%;
            padding: 5%;
            background: #fff;
            margin: 0 auto;

        }

        .rank td {
            vertical-align: initial !important;
        }

        .rank li {
            width: 90%;
            border-bottom: 1px solid #ccc;
            height: 50px;
            margin: 0 auto;
            list-style-type: none;
            line-height: 50px;
        }

        .rank img {
            width: 40px;
            height: 40px;
            border-radius: 50%
        }

        .rank h4 {
            text-align: center
        }
    </style>
    <div class="mask">
        {if $setting['rankimage']}
        <img src="../attachment/{$setting['rankimage']}" alt="" width="100%"> {else}
        <img src="{$url['style']}/image/mask.jpg" alt="" width="100%"> {/if}
        <div class="rank mask-wp">
            <h4>排行榜</h4>
            <table class="table">
                <thead>
                    <tr>
                        <th></th>
                        <th>头像</th>
                        <th>名字</th>
                        <th>分数</th>
                        <th>最高</th>
                    </tr>
                </thead>
                <tbody id="ranklist">
                </tbody>
            </table>
        </div>
    </div>
    <div class="mooncake_wp">
        <div class="mn_wp">
            <a class="go_back" href="javascript:;">再打一次</a>

        </div>
    </div>
    <script type="text/javascript" src="{$url['style']}/js/main.js"></script>
    <script>
        var audio;
        $(function () {
            initAudio();
            audio.play();
        });
        var initAudio = function () {
            audio = document.getElementById('bg_music');
        };
        function playOrPaused(obj) {
            if (audio.paused) {
                audio.play();
                obj.innerHTML = '暂停';
                obj.className = '';
                return;
            }
            audio.pause();
            obj.innerHTML = '播放';
            obj.className = 'music_pause';
        }

        $(function () {
            var _n = $(window).width() / $(window).height();
            if (_n < 1) {
                $('.roll_tips').hide();
            }
            else {
                $('.roll_tips').show();
            };

            $(".fz_btn").click(function () {
                location.reload();
            });

            $(".zf_bt").click(function () {
                $(".mask").show();
            });
            $(".mask").click(function () {
                $(this).hide();
            });
            $(".dh_btn").click(function () {
                $(".mooncake_wp").show();
            });
            $(".go_back").click(function () {
                jixu();
            });
        });
        //难度配置

        xxz = { hp: {$xxz['hp']}, sd: {$xxz['sd']}, df: {$xxz['df']} };
        zxz = { hp: {$zxz['hp']}, sd: {$zxz['sd']}, df: {$zxz['df']} };
        dxz = { hp: {$dxz['hp']}, sd: {$dxz['sd']}, df: {$dxz['df']} };

        apiurl = "{$url['api']}";

    </script>
</body>

<script>

    wx.ready(function () {
        sharedata = {
            title: '我在玩王校长吃热狗',
            desc: '我正在玩王校长吃热狗，大家一起来玩呀',
            link: '{$url['link']}',
            imgUrl: '{$url['icon']}',
            success: function () {
                $.ajax({
                    type: "POST",
                    url: apiurl+"&op=shareup",
                    data: { share: 1 },
                    success: function (data) {
                        if (data) { alert('分享成功'); }
                    }
                });
            },
            cancel: function () {
                alert('cancel');
            }
        };
        wx.onMenuShareAppMessage(sharedata);
    });


    //分享和排行榜
    $(".zf_bt").click(function () {
        score = $("#planscore").text();

        $.ajax({
            type: "GET",
            url: "{$url['api']}&op=rank",
            data: { share: 1 },
            success: function (data) {
                $("#ranklist").html(data);
            }
        });

        wx.ready(function () {
            sharedata = {
                title: '我在玩王校长吃热狗',
                desc: '我在总共给王校长吃了' + score + '根热狗，你也来试试吧。',
                link: '{$url['link']}',
                imgUrl: '{$url['icon']}',
                success: function () {
                    // alert('success');
                    $.ajax({
                        type: "POST",
                        url: apiurl+"&op=shareup",
                        data: { share: 1 },
                        success: function (data) {
                            if (data) { alert('分享成功'); }
                        }
                    });
                },
                cancel: function () {
                    alert('cancel');
                }
            };
            wx.onMenuShareAppMessage(sharedata);
        });
    });
</script> {template 'footer'}